package kuzmenkov.oip.model.dao.hibernate.impl;

import kuzmenkov.oip.model.MethodClass;
import kuzmenkov.oip.model.dao.hibernate.MethodClassDao;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Expression;
import org.springframework.dao.DataAccessException;

import java.util.List;

/**
 * @see kuzmenkov.oip.model.dao.hibernate.MethodClassDao
 * User: Michael Kuzmenkov
 * Date: 16.03.2009
 * Time: 12:05:03
 */
public class MethodClassDaoImpl extends GenericDaoImpl<MethodClass, Long> implements MethodClassDao {

    /**
     * @see kuzmenkov.oip.model.dao.hibernate.MethodClassDao#findSubclasses(Long) 
     */
    public List<MethodClass> findSubclasses(Long classId) throws DataAccessException {

        DetachedCriteria criteria = DetachedCriteria.forClass(MethodClass.class);
        criteria.add(Expression.eq("superclassId", classId));

        List<MethodClass> subclasses = getHibernateTemplate().findByCriteria(criteria);

        return subclasses;
    }
}